import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yi_shop/components/evaluate/index.dart';
import 'package:yi_shop/ui/keep_alive.dart';
import 'package:yi_shop/utils/styles.dart';
import 'package:yi_shop/utils/tools.dart';

class EvaluateCenterController extends GetxController with GetSingleTickerProviderStateMixin {
  late TabController controller;
  List<String> tabs = ['待评价（5）', '已评价（6）'];

  @override
  void onInit() {
    controller = TabController(length: tabs.length, vsync: this);
    super.onInit();
  }

  @override
  void onClose() {
    controller.dispose();
    super.onClose();
  }
}

class EvaluateCenterPage extends GetView<EvaluateCenterController> {
  const EvaluateCenterPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: ToolsUtils.builderLeading(),
        title: Text(
          '评价中心',
          style: StylesUtils.customTextStyle(
              fontWeight: FontWeight.w700, fontSize: StylesUtils.fontSize18),
        ),
        bottom: PreferredSize(
            preferredSize: const Size.fromHeight(50),
            child: Container(
              color: Colors.white,
              height: 45,
              child: ToolsUtils.getClientTabBar(controller.tabs, controller.controller,
                  isScrollable: false, indicatorSize: TabBarIndicatorSize.tab),
            )),
      ),
      body: TabBarView(
        controller: controller.controller,
        children: [
          KeepAliveWrapperTabView(
            child: const StayEvaluateView(),
            callback: () {
              Get.put(() => StayEvaluateController());
            },
          ),
          KeepAliveWrapperTabView(
              child: const RatedEvaluateView(),
              callback: () {
                Get.put(RatedEvaluateController());
              }),
        ],
      ),
    );
  }
}
